﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using MvcDataTables;

namespace MvcDataTablesDemo.Models
{
    public class FileModel
    {
        private readonly FileInfo _fileInfo;

        public FileModel() {}

        public FileModel(FileInfo fileInfo)
        {
            _fileInfo = fileInfo;
            Name = _fileInfo.Name;
            IsReadOnly = _fileInfo.IsReadOnly;            
        }

        [EditableColumn]
        public string Name { get; set; }
        public string Extension { get { return _fileInfo != null ? _fileInfo.Extension : null; } }
        [EditableColumn]
        public bool IsReadOnly { get; set; }
        public long Length { get { return _fileInfo != null ? _fileInfo.Length : 0; } }
        public DateTime CreateDateTime { get { return _fileInfo != null ? _fileInfo.CreationTime : DateTime.MinValue; } }
    }
}